###################################################################
############### Data mining: eclat in R
##Itemset. - A collection of one or more items. 
##. Example: {Milk, Bread, Diaper}
##  a set of items that appears in many baskets is said to be "frequent."

library(arules)
library(arulesViz)
library(datasets)

data("Adult")

inspect(head(Adult, 5))


size(head(Adult))

## we apply the arules eclat algorithm 
##generated. We creae itemset minimum support of .1,
#The output of the algorithm are the association rules together with the confidence 

itemsets = eclat (Adult, parameter = list(supp = 0.5, 
                                                    maxlen = 5)) # Min Support as 0.001, confidence as 0.8.

## Display the 5 itemsets with the highest support.
top5 = sort(itemsets)
head(inspect(top5))

## Get the itemsets as a list
as(items(top5), "list")

as(items(top5), "matrix")